package com.tudouji.project.produce.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.project.produce.domain.Produceplanitem;
import com.tudouji.project.produce.service.IProduceplanitemService;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.web.page.TableDataInfo;

/**
 * 生产计划明细Controller
 * 
 * @author tudouji
 * @date 2022-06-01
 */
@RestController
@RequestMapping("/produce/item")
public class ProduceplanitemController extends BaseController
{
    @Autowired
    private IProduceplanitemService produceplanitemService;

    /**
     * 查询生产计划明细列表
     */
    @PreAuthorize("@ss.hasPermi('produce:item:list')")
    @GetMapping("/list")
    public TableDataInfo list(Produceplanitem produceplanitem)
    {
        startPage();
        List<Produceplanitem> list = produceplanitemService.selectProduceplanitemList(produceplanitem);
        return getDataTable(list);
    }

    /**
     * 导出生产计划明细列表
     */
    @PreAuthorize("@ss.hasPermi('produce:item:export')")
    @Log(title = "生产计划明细", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Produceplanitem produceplanitem)
    {
        List<Produceplanitem> list = produceplanitemService.selectProduceplanitemList(produceplanitem);
        ExcelUtil<Produceplanitem> util = new ExcelUtil<Produceplanitem>(Produceplanitem.class);
        return util.exportExcel(list, "item");
    }

    /**
     * 获取生产计划明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('produce:item:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(produceplanitemService.selectProduceplanitemById(guid));
    }

    /**
     * 新增生产计划明细
     */
    @PreAuthorize("@ss.hasPermi('produce:item:add')")
    @Log(title = "生产计划明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Produceplanitem produceplanitem)
    {
        return toAjax(produceplanitemService.insertProduceplanitem(produceplanitem));
    }

    /**
     * 修改生产计划明细
     */
    @PreAuthorize("@ss.hasPermi('produce:item:edit')")
    @Log(title = "生产计划明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Produceplanitem produceplanitem)
    {
        return toAjax(produceplanitemService.updateProduceplanitem(produceplanitem));
    }

    /**
     * 删除生产计划明细
     */
    @PreAuthorize("@ss.hasPermi('produce:item:remove')")
    @Log(title = "生产计划明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(produceplanitemService.deleteProduceplanitemByIds(guids));
    }
}
